import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// router 的自动导入
const moduleFn = require.context('./routes' , false , /\.js$/i)
const routes = moduleFn.keys().reduce((prev , curr) => {
  prev.push(moduleFn(curr).default)
  return prev
},[])

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
